<extend name="../layout" />

<block name="main_content">
    <include file="Common:SettingsHeader:order" />
    <div class="widget-box">
        <div class="widget-title"> <span class="icon"> <i class="icon-info-sign"></i> </span>
            <h5>{:L('orders_list')}</h5>
            <a href="javascript:add();" class="label label-info">{:L('add_new')}</a>
        </div>
        <div class="widget-content nopadding">
            <table id="theTable" class="table table-bordered table-striped with-check" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <th width="8">
                            ID
                        </th>
                        <th><a field="subject" href="javascript:sortBy('subject','1','index')">{:L("subject")}</a></th>
                        <th><a field="saler_id" href="javascript:sortBy('saler_id','1','index')">{:L("saler")}</a></th>
                        <th><a field="sale_type" href="javascript:sortBy('sale_type','1','index')">{:L("sale_type")}</a></th>
                        <th><a field="customer_id" href="javascript:sortBy('customer_id','1','index')">{:L("customer")}</a></th>
                        <th><a field="total_num" href="javascript:sortBy('total_num','1','index')">{:L("total_num")}</a></th>
                        <th><a field="total_price" href="javascript:sortBy('total_price','1','index')">{:L("total_price")}</a></th>
                        <th><a field="total_price_real" href="javascript:sortBy('total_price_real','1','index')">{:L("total_price_real")}</a></th>
                        <th><a field="dateline" href="javascript:sortBy('dateline','1','index')">{:L("dateline")}</a></th>
                        <th><a field="status" href="javascript:sortBy('status','1','index')">{:L("status")}</a></th>
                        <th><a field="status" href="javascript:sortBy('status','1','index')">{:L("memo")}</a></th>
                        <th>{:L("operation")}</th>
                    </tr>
                </thead>
                <tbody>
                    <volist name="list" id="l">
                        <tr>
                            <td>
                                {$l.id}
                            </td>
                            <td>
                                <a href="javascript:viewDetail({$l.id})">{$l.subject}</a>
                            </td>
                            <td>{$l.sponsor}</td>
                            <td>{$l.sale_type|toSaleType}</td>
                            <td><a href="{:U('/CRM/Customer/viewDetail/id/'.$l[customer_id])}">{$l.customer_name}</a></td>
                            <td>{$l.total_num}</td>
                            <td>{$l.total_price}</td>
                            <td>{$l.total_price_real}</td>
                            <td>{$l.dateline|toDate='m-d H:i'}</td>
                            <td>
                                <span class="badge badge-{$l.processes.currentNode.status_class}">
                                    {$l.processes.currentNode.status_text}
                                </span>
                            </td>
                            <td>
                                {$l.processes.prevProcess.memo}
                            </td>
                            <td>
                                <if condition="$l[status] eq 0">
                                    <a href="javascript:editDetail({$l.id});" class="btn btn-mini btn-primary">{:L('edit_detail')}</a>
                                    <a href="javascript:del({$l.id});" class="btn btn-mini btn-danger">{:L('delete')}</a>
                                <else />
                                    <a href="javascript:viewDetail({$l.id});" class="btn btn-mini btn-primary">{:L('view_detail')}</a>
                                </if>
                                <volist name="l[processes][nextNodes]" id="lpn">
                                    <a href="{:U('/JXC/Orders/doWorkflow/node_id/'.$lpn[id].'/mainrow_id/'.$l[id])}" class="btn btn-mini btn-{$lpn.btn_class}">{$lpn.name}</a> &nbsp;
                                </volist>
                            </td>
                        </tr>
                    </volist>
                    <tr>
                        <td colspan="11">
                            <div class="pagination alternate"><ul>{$page}</ul></div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</block>

<block name="footer_js">
    <if condition="$sortField">
    <script type="text/javascript">
        $(function(){
            $("#theTable thead a[field='{$sortField}']").append('<i class="icon {$sortImg}"></i> ')
            .attr("href", "javascript:sortBy('{$sortField}','{$sort}','index')");
        });
    </script>
    </if>
</block>